#include "types/common.h"
#include "types/record.h"
#include "types/bptree.h"

#ifndef _recinfo_cache_h_
#define _recinfo_cache_h_

//Container that can hold the record information cache
//It will cache the block number, table name and the modified slot number in the block
//Only uncommitted buffers will be cached. 
//On commit the cache entry will be flushed using the call back.
class recinfo_cache
{
public:
	static inline recinfo_cache *inst()
	{
		if(rc == NULL)
		{
			rc = new recinfo_cache;
		}
		return rc;
	}
	
	recinfo_cache();
	void insert(string &tblname, Record r, vector<string> index_name);
	void insert(string &tblname, Record r);
	vector<Record> get_uncommitted_records(string tblname);
	void flush_cache(string &tablename, UINT32 block_num);
	bool is_cached(RecordId id);
	
private:
	static recinfo_cache *rc;
	struct info
	{
		string tablename;
		Record r;
		vector<string> indices;
	};
	
	vector<info> cache;
};

#endif
